import {
  Component
} from 'react';

import {
  Toast,
  Button,
  TabBar,
} from 'saltui';

import './PageHome.less';

export default class PageHome extends Component {

  constructor(props) {
    super(props);
    dd.ui.webViewBounce.disable();
    var hasBottomTab =  document.getElementById("hasBottomTab").value;
    this.state = {
      activeIndex: props.activeIndex,
      hasBottomTab: hasBottomTab,
    }

    this.tabBarItems = [{
      title: '论坛首页',
      icon: <span className="iconfont icon-forum"></span>,
      path: '/star',
    }, {
      title: '版块导航',
      icon: <span className="iconfont icon-app"></span>,
      /*badge: 'new',
       badgeStyle: { right: -5 },*/
      path: '/a/star',
    }, {
      title: '我的论坛',
      icon: <span className="iconfont icon-mine"></span>,
      path: '/b/star'
    }];
  }

  onChange = (activeIndex) => {
    if(this.state.activeIndex == 2){
      this.props.changeTabMy();
    }
    this.setState({
      activeIndex: activeIndex
    });
    if (activeIndex == 0) {
      location.href = "#/post/page";
    } else if (activeIndex == 1) {
      location.href = '#/board/navigate';
    } else if (activeIndex == 2) {
      location.href = '#/my/page';
    }

  }

  render() {
    const t = this;
    let tabBarStyle = {};
    return (
      <div>
      <div className={t.state.hasBottomTab == "0"?"t-DN":""}>
        <TabBar
          tabBarStyle={tabBarStyle}
          activeIndex={this.state.activeIndex}
          iconHeight={24}
          cIconHeight={50}
          onChange={this.onChange}
          items={this.tabBarItems}
        ></TabBar>
        </div>
      </div>
    );
  }
}